package web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.Member;
import beans.PersonInformation;
import beans.Success;
import service.SearchPeople;
import service.SuccessService;
import serviceimpl.SearchPeopleIpmt;
import serviceimpl.SuccessServiceIpmt;

/**
 * Servlet implementation class SuccessServlet
 */
@WebServlet("/SuccessServlet")
public class SuccessServlet extends HttpServlet {
	private List<PersonInformation> p;
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		SuccessService ss = new SuccessServiceIpmt();
		SearchPeople sp = new SearchPeopleIpmt();
		List<Success> list = ss.listAllSuccess();
		request.getSession().setAttribute("success", list);
		Member member = (Member) request.getSession().getAttribute("member");
		if(member.getGendar().equals("男")) {
			p = sp.findMemberByGendar("女");
		}else {
			p = sp.findMemberByGendar("男");
		}
		request.getSession().setAttribute("PersonInformations", p);

		response.sendRedirect("/zzLoveProduct/index/index.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
